<?php
/**
 * @description : success page for third payment of h3g
 * @author      : stephen.mo
 * @date        : Nov 11,2010
 */
require_once "TVB/OAuth/common.inc.php";
#ini_set("display_errors","on");

$oauth_callback  = (isset($_REQUEST['oauth_callback'])) ? $_REQUEST['oauth_callback'] : NULL;
$tvbauth = (isset($_REQUEST['tvbauth'])) ? $_REQUEST['tvbauth'] : NULL;
$msisdn = (isset($_REQUEST['msisdn'])) ? $_REQUEST['msisdn'] : NULL;
$base_server_path  = OAuthConfig::OAuthDomainUrl($_SERVER);
$message_url       = $base_server_path.OAuthConfig::DEFAULT_SHOW_MESSAGE_URL;

//all necessary parameters not allow null.
if (empty($oauth_callback) || empty($msisdn)) {
    $retry = (!empty($oauth_callback)) ? $oauth_callback : '#';
    $other_msg = array('call_back'=>urlencode($retry));
    OAuthUtils::toMessageUrl($message_url,OAuthModelConfig::M_PAGE_OF_ERROR,OAuthModelConfig::DEFAULT_CONST_FALIURE,$lang,array(1035,1037),$other_msg);
    exit;
}

//to analyze a url and get some necessary parameter.
$param_vars = array();
if (!empty($oauth_callback)) {
    $query_param_vars  = parse_url($oauth_callback);
    if (isset($query_param_vars['query'])) {
        parse_str($query_param_vars['query'],$param_vars);
    }
}

//parameter setting.
$lang = (isset($param_vars['lang'])) ? $param_vars['lang'] : 'zh-hant-hk';
$call_back = (isset($param_vars['call_back'])) ? $param_vars['call_back'] : '#';
$network_type      = (isset($param_vars['ntype'])) ? $param_vars['ntype'] : NULL;

//get the mapping error codes.
//$current_err_code   = OAuthUtils::getCurrentMappingErrCode($error_code);
$current_err_code[] = 1041;
$other_msg          = array('call_back'=>urlencode($call_back));
OAuthUtils::toMessageUrl($message_url,OAuthModelConfig::M_PAGE_OF_ERROR,OAuthModelConfig::DEFAULT_CONST_FALIURE,$lang,$current_err_code,$other_msg);
exit;
?>

